package org.kishidogames.shonerumble.screen;

import org.kishidogames.shonerumble.ShonenRumble;

import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.badlogic.gdx.graphics.g2d.TextureRegion;
import com.badlogic.gdx.math.Matrix4;

public abstract class Screen {

	private ShonenRumble shonenRumble;

	public SpriteBatch spriteBatch;

	public void removed() {
		spriteBatch.dispose();
	}
	
	public final void init(ShonenRumble shonenRumble) {
		this.shonenRumble = shonenRumble;
		Matrix4 projection = new Matrix4();
		projection.setToOrtho(0, 320, 240, 0, -1, 1);

		spriteBatch = new SpriteBatch(100);
		spriteBatch.setProjectionMatrix(projection);
	}

	protected void setScreen(Screen screen) {
		shonenRumble.setScreen(screen);
	}

	public void draw(TextureRegion region, int x, int y) {
		int width = region.getRegionWidth();
		if (width < 0)
			width = -width;
		spriteBatch.draw(region, x, y, width, region.getRegionHeight());
	}

	public abstract void render();
}
